{% extends "forum/base.html" %}
{% load i18n %}

{% block body %}
<div class="space">
    <p>{% trans "Try to fill up all the fields so that you search can produce the best results!" %}</p>
    <form method="POST">
        <div class="clearfix">
            {# -- FORUM -- #}
            <div class="span-12">
                <div title='{%trans "Show items only from the forum..."%}'>{{ form.forum.label_tag }}</div>
                {{ form.forum }}
                {{ form.forum.errors }}
            </div>
            {# -- SORT_METHOD -- #}
            <div class="span-11">
                <div title='{%trans "Order results by..."%}'>{{ form.sort_method.label_tag }}</div>
                {{ form.sort_method }}
                {{ form.sort_method.errors }}
            </div>
            {# -- USERNAME -- #}
            <div class="span-12">
                <div title='{% trans "Show only items from the user..."%}'>{{ form.author.label_tag }}</div>
                {{ form.author }}
                {{ form.author.errors }}
            </div>
            {# -- KEYWORD -- #}
            <div class="span-11">
                <div title='{%trans "Show only items that contains the word[s]..."%}'>{{ form.keyword.label_tag }}</div>
                {{ form.keyword }}
                {{ form.keyword.errors }}
            </div>
            {# -- DATE -- #}
            <div class="span-12">
                <div title='{%trans "Show only items created after..."%}'>{{ form.date.label_tag }}</div>
                {{ form.date }}
                {{ form.date.errors }}
            </div>            
        </div>
        <div class="clearfix">
            <input class="button" type="submit" name="_search" value='{% trans "Search" %}' />
            <input class="button" type="reset" value='{% trans "Clear" %}' />
        </div>
    </form>
    
    {% if page %}
    <div class="clearfix hspace"></div>
    
    {% if page.paginator.count %}    
    {% include "forum/includes/digg_paginator.html" %}
    
    <table id="search_result">
        <thead>
            <tr>
                <th class="cell-name">{% trans "Name" %}</th>
                <th class="cell-author">{% trans "Author" %}</th>
                <th class="cell-posts">{% trans "Replies" %}</th>
                <th class="cell-views">{% trans "Views" %}</th>
                <th class="cell-created">{% trans "Created" %}</th>
            </tr>
        </thead>
        <tbody>        
        {% for topic in page.object_list %}
            <tr {% if forloop.counter|divisibleby:2 %}class="mark"{% endif %}>
                <td class="cell-name"><a 
                    {% if topic.is_topic %}
                    title='{% trans "User topic"%}'
                    {% else %}
                    title='{% trans "User answer"%}'
                    {% endif %}
                    href="{{topic.link}}">{{topic}}</a></td>
                <td class="cell-author"><a href="{% url forum-user-profile topic.username %}">{{topic.author}}</a></td>
                <td class="cell-posts">{{topic.reply_count}}</td>
                <td class="cell-views">{{topic.views_count}}</td>
                <td class="cell-created">{{topic.created_time|date}}</td>
            </tr>
        {% endfor %}
        </tbody>
        <tfoot>
            <tr>
                <td class="cell-name">{% trans "Name" %}</th>
                <td class="cell-author">{% trans "Author" %}</th>
                <td class="cell-posts">{% trans "Replies" %}</th>
                <td class="cell-views">{% trans "Views" %}</th>
                <td class="cell-created">{% trans "Created" %}</th>
            </tr>
        </tfoot>
    </table>
    
    {% include "forum/includes/digg_paginator.html" %}
    {% else %}
    <div class="notice">
        {% trans "Your search produced no results. Try to be less especific. ; )" %}
    </div>
    {% endif %} {# IF page.paginator.count #}
    {% endif %} {# IF page #}
</div>{# fim do espaçamento #}
{% endblock body %}
